<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>你办囍事 我送囍酒</title>
		<meta name="viewport" content="width=640,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="/Public/game/css/reset.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo  C('HTTP_HOST_URL');?>/Public/game/css/Redeem.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo  C('HTTP_HOST_URL');?>/Public/game/css/animate.css" />
	</head>

	<body>
		<include file="./Application/Home/View/Page/wechatsdk.html" />
		<div class="web"> 
			<ul>
				<li>请输入兑换码</li>
                <li><input type="text" class="code" /></li>
				<li><span class="confirm button">确 认</span></li>
			</ul>
			<div class="bot">
				<button class="goUrl"></button>
			</div>
			<div class="mask">
				<div class="box">
					<div class="result success animated bounceIn">
						<ul>
							<li><span class="remove"><img src="/Public/game/images/close_icon.jpg"/></span></li>
							<li><span class="textContent">兑换成功!</span></li>
						</ul>
					</div>
					<div class="result fail animated bounceIn">
						<ul>
							<li><span><img src="/Public/game/images/close_icon.jpg"/></span></li>
							<li>
                                <span>输入错误<br/>请注意区分字母大小写</span>
                            </li>
							<li><button>重新输入</button></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<script src="<?php echo  C('HTTP_HOST_URL');?>/Public/game/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
        <script src="<?php echo  C('HTTP_HOST_URL');?>/Public/game/js/jQuery.md5.js" type="text/javascript" charset="utf-8"></script>
        
		<script type="text/javascript">
            var number = 'lkasdj213489ulkjadsf';
			$(".web .confirm").on("click",function(){
                var code = $(".code").val();
                var postData = {"code":code};
                var qwer = JSON.stringify(postData);
                var asdf = $.md5(qwer + number);
                var url = '<php>echo \Org\Net\Fun::url("home/page/verificationCode")</php>';

                var postData = {'qwer':qwer,"session_id":asdf};
                $.post(url,postData,function(data){
                    if(data.state==1){
                        $(".textContent").text(data.message)
                        $(".mask, .success").css("display","block");
                    } else {
                        $(".mask, .fail").css("display","block");
                    }                    
                },"json");
                
                
//				if($(".web ul:first input").val()!=""){
//					$(".mask, .success").css("display","block");
//				}else{
//					$(".mask, .fail").css("display","block");
//				}
			})
			$(".result .remove").on("click",function(){
				$(".mask").css("display","none");
			})
			$(".result.fail li:last button").on("click",function(){
				$(".mask").css("display","none");
				$(".web ul:first-of-type input").focus();
			})
			$(".result.fail li:first span").on("click",function(){
				$(".mask").css("display","none");
			});
            
            $(".goUrl").click(function(){
                location.href = "<php>echo \Org\Net\Fun::url('home/page/index');</php>";
            });
		</script>
	</body>

</html>